package com.example.mybatis_demo.service;

import com.example.mybatis_demo.mapper.UserMapper;
import com.example.mybatis_demo.model.ArticleInfo;
import com.example.mybatis_demo.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2022-12-19
 * Time: 13:21
 */

@Service
public class UserService {
    @Autowired
    public UserMapper userMapper;

    public User getUserById(Integer id){
        return userMapper.getUserById(id);
    }

    public int updateById(Integer id, String name){
        return  userMapper.updateById(id,name);
    }

    public int add(User user){
        return userMapper.add(user);
    }

    //自增主键增加 获取增加之后 对象的id
    public int add1(User user){
        return userMapper.add1(user);
    }

    //删除
    public int del(Integer id){
        return userMapper.del(id);
    }


    //更具id来进行排序
    public List<User> getOrder(String order){
        return userMapper.getIdOrder(order);
    }


    //like模糊查询
    public List<User> getLike(String username){
        return userMapper.getLike(username);
    }

    //根据id来查询
    public User getIdMap(Integer id){
        return userMapper.getIdMap(id);
    }

    //动态SQL
    public int add2(User user){
        return userMapper.add2(user);
    }
}
